<template name='pick_records'>

<view >
	<!-- 商品信息-右边 -->
	<view class="box-infos   font12" >
		
		<view class="content-box ">
			<view class="boxsss">
				<!-- 增加、删除 -->
				<view class="top-but menu-scroll-w">
					<view class="top-but-box ">
						
						<!-- 时间 筛选 -->
						<!-- <text selectable="true"  class="justify">时间范围:</text> -->
						<view class=" date-center floatleft" >
							
							<picker class="date-left" 
							mode="date" 
							:value="search.date[0]" 
							@change="changeStartDate"
							>
								<view class="uni-input cursor">{{search.date.length >0 ? search.date[0]:'开始时间'}}</view>
							</picker>
							
							<view class="date-c"> - </view>
							
							<picker class="date-left" 
							mode="date" 
							:value="search.date[1]" 
							@change="changeEndDate"
							>
								<view class="uni-input cursor">{{search.date.length >1 ? search.date[1]:'结束时间'}}</view>
							</picker>
							
							<view class="delete-ipu" 
							style="position: unset;transform: none;"
							v-if="search.date.length >1" 
							@click="search.date=[],funOrderAllAdmin(true)"
							>
								<img src="../../static/img/delete-1.png"  ></img>
							</view>
						</view>
						<!-- end -->
						
					
				
					
						<!-- end -->
						<!-- 线路 筛选 -->
						<view class="flex floatleft" >
							<text selectable="true"  class="riskTitle " >选择线路:</text>
							<view class="input_confirms" >
								<uni-data-select
								:localdata="$routeData.getRoute()"
								v-model="search.route_id"
								@change="funOrderAllAdmin(true)"
								placeholder="选择线路"
								placeholder-class="placeholder-class"
								class="color-e40318"
								></uni-data-select>
							</view>
						</view>
						<!-- end -->
						
						<!-- 搜索员工 -->
						<view class="flex floatleft" >
							<text selectable="true"  class="riskTitle " >拣货人:</text>
							<view class="input_confirms" >
								<uni-data-select
								:localdata="$routeData.getYuangong()"
								v-model="search.yuangongId"
								@change="funOrderAllAdmin(true)"
								placeholder="选择拣货人"
								placeholder-class="placeholder-class"
								class="color-e40318"
								></uni-data-select>
							</view>
						</view>
						<!-- end -->
						
						
						<!-- 客户名称-->
						<view class="flex floatleft" >
							<text selectable="true"  class="riskTitle " >客户名称:</text>
							<!-- 搜索 -->
							<view class="searchBox" style="min-width: 100px;max-width: 150px;">
								<input 
								v-model="search.user_value"
								
								placeholder="输入搜索关键字"
								placeholder-class="placeholder-class"
								@confirm="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)"
								class="search-ipu "
								/>
								<view class="delete-ipu" v-if="search.user_value!=''" @click="search.user_value='',funOrderAllAdmin(true)">
									<img src="../../static/img/delete-1.png"  ></img>
								</view>
							</view>
						</view>
						<!-- end -->
						
						<!-- 商品名称-->
						<view class="flex floatleft" >
							<text selectable="true"  class="riskTitle " >商品名称:</text>
							<!-- 搜索 -->
							<view class="searchBox" style="min-width: 100px;max-width: 150px;">
								<input 
								v-model="search.goods_value"
								
								placeholder="输入搜索关键字"
								placeholder-class="placeholder-class"
								@confirm="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)"
								class="search-ipu "
								/>
								<view class="delete-ipu" v-if="search.goods_value!=''" @click="search.goods_value='',funOrderAllAdmin(true)">
									<img src="../../static/img/delete-1.png"  ></img>
								</view>
							</view>
						</view>
						<!-- end -->
						
						<!-- 订单号-->
						<view class="flex floatleft" >
							<text selectable="true"  class="riskTitle " >订单号:</text>
							<!-- 搜索 -->
							<view class="searchBox" style="min-width: 100px;max-width: 150px;">
								<input 
								v-model="search.order_id"
								
								placeholder="输入搜索订单号关键字"
								placeholder-class="placeholder-class"
								@confirm="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)"
								class="search-ipu "
								/>
								<view class="delete-ipu" v-if="search.order_id!=''" @click="search.order_id='',funOrderAllAdmin(true)">
									<img src="../../static/img/delete-1.png"  ></img>
								</view>
							</view>
						</view>
						<!-- end -->
								
						<!-- 时间 筛选 -->
						<view 
							@click="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)" 
							class="rightButttom" 
						>
							<img src="../../static/img/search.png" class="ico"></img>
							刷新
						</view>
						
						<view 
							@click="emptyData()" 
							class="back_color search-but floatleft" 
						>
							<img src="../../static/img/delete.png" class="ico"></img>
							重置
						</view>
					
					</view>
				</view>
				<table v-if="resData.list!=undefined && resData.list.length>0">
					<!-- 表头 -->
					<thead>
						<tr >
							<th style="min-width: 20px;">
								序
							</th>
							<th class="centers">线路</th>
							<th class="centers">单号</th>
							<th class="centers">客户</th>
							<th>商品</th>
							<th class="centers">数量</th>
							<th class="centers">操作人</th>
						</tr>
					</thead>
					<tbody>
					
							<!-- 内容 -->
							<tr v-for="(item,index) in resData.list" 
							:key="index"  
							@click="TabcheckedIndex = index"
							:class="TabcheckedIndex == index ? 'goods-list-select':''"
							>
								<td>
									{{index+1}}
								</td>
								<td class="centers">
									{{item.route_name}}
								</td>
								
								<td class="centers" @click="$common.GetOrder(item.order_id,false,2)">
									{{item.order_id}}
								</td>
								<td class="centers alter"
								@click="openUser(item.user_id,item.uid_name,'kh')"
								>
									{{item.user_name}}
								</td>
								
								<td class=" alter"
								@click="openGoods(item.goods_id,item.goods_name)"
								>
									{{item.goods_name}}
								</td>
								
								<td class="centers">
									{{item.counts}}
								</td>
								
								<td class="centers alter"
								@click="openUser(item.uids,item.uids_name,'yg')"
								>
									{{item.uids_name}}
								</td>
								
							</tr>
					
					</tbody>
				</table>
				
				<!-- 暂无数据 -->
				<empty v-if="resData.list==undefined || resData.list.length==0"></empty>
				<!-- end -->
			</view>
			
		
		
			<!-- 页码 -->
			<pages 
			:sum="page.sum"
			:current="page.nowPage"
			@updatePage="updatePage"
			></pages>
			<!-- end -->
		</view>
		<!-- 数据列表end -->
		

	
		<!-- 用户详情页 -->
		<uni-popup ref="page_admin" type="center" :title="pageSend.name" 
		>
			<person_admin
			:OnPageSearchUserId="pageSend.user_id" 
			status="firm_user_list" 
			class="page-boxs h100"
			:sendType="pageSend.sendType"
			></person_admin>	
		</uni-popup>
		<!-- end -->
		<!-- 商品页面 -->
		<uni-popup ref="pageSendGoods" type="center" :title="pageSendGoods.name"
		
		>
			<shopping_admin :isPop="false" :OnPageSearchGoodsId="pageSendGoods.id"  class="h100"></shopping_admin>
		</uni-popup>
		<!-- end -->
	</view>
	<!-- end -->
</view>

</template>

<script>
	import pages from "@/components/admin-components/pages.vue"
	import empty from "@/components/admin-components/empty.vue"
	import person_admin from "@/components/user/list.vue"
	import shopping_admin from "@/components/goods/goods.vue"

	
	export default{
		name:'pick_records',
		components: {
			pages,empty,person_admin,shopping_admin
		},
		beforeCreate(){
			this.$options.components.order_money = require('@/components/admin-components/order_money.vue').default 
		},
		data(){
			return{
				TabcheckedIndex:-1,//当前选中项
				PrintOrderData:{},//欲要打印的订单数据
				pageSend:{
					user_id:'',
					name:''
				},
				pageSendGoods:{
					id:'',
					name:''
				},
			
				search:{
					date:[],
					user_value:'',
					goods_value:'',
					order_id:'',
					route_id:'',
					yuangongId:'',
				},
				page:{
					nowPage:1,//当前页数
					pageCount:1,//总页数
					maxCount:0,
					sum:0,
					pageCounts:15,
				},
			
				resData:{},
			}
		},
		 // 此处定义传入的数据
		props: {
			/**
			 * 其他页面传递进来直接搜寻的，不是菜单打开的
			*/
			onSearch: {
				type:Object,
				default :''
			},
		},
		mounted(){
		},
		created() {
			if(this.onSearch.date){
				this.search = this.onSearch
				
				//不是模块打开的华就提取线路
				
			}else{
				let route = this.$routeData.GetNowRoute()
				this.search.route_id = route
				
			}

			
			
			
			

			this.funOrderAllAdmin(true)
		},
		methods:{
			openUser(id,name,sendType){
				this.pageSend.sendType = sendType
				this.pageSend.user_id = id
				this.pageSend.name = name
				this.$refs.page_admin.open()
			},
			openGoods(id,name){
				this.pageSendGoods.id = id
				this.pageSendGoods.name = name
				this.$refs.pageSendGoods.open()
			},
			//回调第一个时间
			changeStartDate(res){
				this.search.date[0] = res.detail.value
				this.$set(this.search.date,0,this.search.date[0])
				//this.funOrderAllAdmin(true)
			},
			//回调第二个时间
			changeEndDate(res){
				this.search.date[1] = res.detail.value
				this.$set(this.search.date,1,this.search.date[1])
			},
			/**
			 * 初始化筛选条件
			*/
			emptyData(){
				this.search.user_value=''
				this.search.uid_value =''
				this.search.date =[]
				
				
				this.search.route_id = ''
				this.funOrderAllAdmin(true)
			},
			/**
			 * 线路ID取线路名称
			*/
			routeidGetName(id){
				var tmpArr = this.$routeData.getRoute()
				
				for (var i=0;i<tmpArr.length;i++) {
					if(tmpArr[i].value == id){
						return tmpArr[i].text
					}
				}
				return '-'
			},
			/**
			 * 统计-获取
			*/
			funOrderAllAdmin(isUpdatePage=true){
				var that = this
				//日期构建
				if(that.search.date.length>=2){
					var start_date = that.search.date[0]
					var end_date = that.search.date[1]
				}else{
					var start_date = ''
					var end_date = ''
				}
				that.resData = {}
				that.page.nowPage = isUpdatePage == true ? 1:that.page.nowPage;
				that.$common.get_request(
					{
						type:that.search.actionType==2 ?'ps_list_records_info': 'jh_list_records_info',
						pages:that.page.nowPage,
						page_count:that.page.pageCounts,//当前请求页的数量
						start_date: start_date,
						end_date: end_date,
						route_id: that.search.route_id,
						goods_value: that.search.goods_value,
						order_id: that.search.order_id,
						user_value:that.search.user_value,
						yuangong_id:that.search.yuangongId,
						actionType:that.search.actionType
					},
					(res)=>{
						for (var i=0;i<res.list.length;i++) {
							res.list[i].route_name = that.routeidGetName(res.list[i].route_id)
						}
						that.resData = res
						
						that.page.sum  = res.sum
						if(isUpdatePage == true){
						that.page.nowPage  = 1
						}
					}
				);
			},
			/**
			 * 分页器回调
			 * 
			*/
			updatePage(pageName,pageCount){
				var that = this
				that.page.nowPage = pageName
				that.page.pageCounts = pageCount
				that.funOrderAllAdmin(false)
			},
		}
	}
</script>

<style>
</style>
